package main

import "fmt"

func main() {
	nums := []int{2, 3, 4}
	sum := 0
	// for i := 0; i < len(nums); i++ {
	// 	sum = sum + nums[i]
	// }
	for _, val := range nums {
		sum = sum + val
	}
	fmt.Println("sum", sum)

	for i, val := range nums {
		if val == 3 {
			fmt.Println("index:", i)
		}
	}

	kvs := map[string]string{"a": "apple", "b": "banana"}
	for k, v := range kvs {
		fmt.Printf("%s->%s\n", k, v)
	}

	for k := range kvs {
		fmt.Println("key:", k)
	}

	for _, v := range kvs {
		fmt.Println("val:", v)
	}

	for i, c := range "go" {
		fmt.Printf("i=%c c=%c\n", i, c)
	}
}
